//
//  LinkageSlidingViewController.m
//  project-demo-oc
//
//  Created by 赵隆杰 on 2021/5/31.
//

#import "LinkageSlidingViewController.h"
#import "LinkageSlidingScrollView.h"
#import "LinkageSlidingTopView.h"
#import "LinkageSlidingPageViewController.h"

#define topViewHeight 100

@interface LinkageSlidingViewController ()

@property (nonatomic, strong) LinkageSlidingScrollView *scrollView;
@property (nonatomic, strong) LinkageSlidingTopView *topView;
@property (nonatomic, strong) LinkageSlidingPageViewController *pageVc;

@end

@implementation LinkageSlidingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"联动滑动";
        
    self.scrollView = [[LinkageSlidingScrollView alloc] init];
    [self.view addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.top.mas_equalTo(SL_VC_HEADER_HEIGHT);
    }];
    UIView *scrollContentView = [[UIView alloc] init];
    [self.scrollView addSubview:scrollContentView];
    [scrollContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.scrollView);
        make.centerX.equalTo(self.scrollView);
    }];
    
    self.topView = [[LinkageSlidingTopView alloc] init];
    [scrollContentView addSubview:self.topView];
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(scrollContentView);
        make.height.mas_equalTo(topViewHeight);
    }];
    
    self.pageVc = [[LinkageSlidingPageViewController alloc] init];
    [self addChildViewController:self.pageVc];
    [scrollContentView addSubview:self.pageVc.view];
    [self.pageVc.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topView.mas_bottom);
        make.left.right.bottom.equalTo(scrollContentView);
        make.height.mas_equalTo(SL_WINDOW_HEIGHT - SL_VC_HEADER_HEIGHT);
    }];
}

@end
